<?php

// Get variables

$api = v('api');
$directory = v('directory');
$extensionId = v('extensionId');
$fileName = v('fileName');
$parameters = v('parameters');

// Remove api_

$apiName = substr($api, 4);

?>


<!-- breadcrump -->

<ul class="breadcrumb">
	<li >
		<a href="<?php p(url('[Loop]/page/admin/sandbox/')); ?>" >
			List of files
		</a>
		<span class="divider">/</span>
	</li>
	<li>
		<a href="<?php p(url('[Loop]/page/admin/sandbox/list') . '?extensionId=' . $extensionId .'&directory=' . $directory . '&fileName=' . $fileName);?>">		<?php p($extensionId);?>/ <?php p($directory);?>/<?php p($fileName);?>
		</a>
		<span class="divider">/</span>
		</li>
	<li class="active">
		<?php p($apiName); ?>
	</li>
</ul>


<h4 style="text-align: center;"><?php p($apiName); ?></h4>

<div id="resultApi" name="resultApi" style="color:red;font-size:20px;"></div>
<hr>

<?php

	// If there is parameters, construct the form

	if (count($parameters) > 0)
	{
		
?>
		<form id="sandboxApi" name="sandboxApi" class="form-horizontal" method="post">
			<input type="hidden" id="extensionId" name="extensionId" 	value="<?php p($extensionId); ?>">
			<input type="hidden" id="apiName" name="apiName" value="<?php p($apiName); ?>"	>
			<input type="hidden" id="className" name="className" value="<?php p(substr($fileName,1)); ?>">

			<?php 
				foreach ($parameters['arguments'] as $paramName => $paramDetails)
				{
					// Remove the $

					$paramName = substr($paramName, 1);
			?>
					<div class="control-group">
						<label class="control-label" for="<?php p($paramName); ?>">
							<?php p($paramName); ?>
							<?php
								if (isset($paramDetails['type']) === true)
								{		
							?>		<br/>
									(<i><?php p($paramDetails['type']); ?></i>)
							<?php
								}
							?>
							<?php
								if (isset($paramDetails['isRequired']) === true && $paramDetails['isRequired'] == 1)
								{		
							?>		<br/>
									(<i>IsRequired</i>)
							<?php
								}
							?>							
						</label>
						<div class="controls">
							<input type="text" id="<?php p($paramName); ?>" name="<?php p($paramName); ?>"  class="input-large" >
							<?php
								if (isset($paramDetails['description']) === true)
								{
							?>
									<i><?php p($paramDetails['description']); ?></i>
							<?php
								}
							?>
						</div>
					</div>
			<?php
				}
			?>
			<div class="control-group">
				<div class="controls">
					<button type="submit" class="btn">Tester</button>	
				</div>
			</div>	
		</form>

<?php
	}
	else
	{
?>

	<p>The method has no description yet, please complete it before test.</p>

<?php
	}
?>

